package designmodel.builder.经典建造者模式;

import java.util.StringJoiner;

/**
 *
 *
 * @author scylla
 * @version V1.0
 * @project echo-java-base
 * @title
 * @package designmodel.builder.经典建造者模式
 * @since 2021/12/15 5:41 下午
 */
public class Computer {

    //必须
    private String cpu;
    //必须
    private String ram;
    //可选
    private int usbCount;
    //可选
    private String keyboard;
    //可选
    private String display;

    public Computer(String cpu, String ram) {
        this.cpu = cpu;
        this.ram = ram;
    }

    public Computer setUsbCount(int usbCount) {
        this.usbCount = usbCount;
        return this;
    }

    public Computer setKeyboard(String keyboard) {
        this.keyboard = keyboard;
        return this;
    }

    public Computer setDisplay(String display) {
        this.display = display;
        return this;
    }

    @Override
    public String toString() {
        return new StringJoiner(", ", Computer.class.getSimpleName() + "[", "]")
                .add("cpu='" + cpu + "'")
                .add("ram='" + ram + "'")
                .add("usbCount=" + usbCount)
                .add("keyboard='" + keyboard + "'")
                .add("display='" + display + "'")
                .toString();
    }
}
